package com.hlxl.viewpoint.model.impl;

import com.hlxl.viewpoint.model.ViewPoint;
import com.hlxl.viewpoint.model.ViewPointModel;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import java.io.Serializable;

import java.sql.Types;

import java.util.HashMap;
import java.util.Map;

/**
 * The base model implementation for the ViewPoint service. Represents a row in the &quot;vp_ViewPoint&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link com.hlxl.viewpoint.model.ViewPointModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ViewPointImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see ViewPointImpl
 * @see com.hlxl.viewpoint.model.ViewPoint
 * @see com.hlxl.viewpoint.model.ViewPointModel
 * @generated
 */
public class ViewPointModelImpl extends BaseModelImpl<ViewPoint>
    implements ViewPointModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a view point model instance should use the {@link com.hlxl.viewpoint.model.ViewPoint} interface instead.
     */
    public static final String TABLE_NAME = "vp_ViewPoint";
    public static final Object[][] TABLE_COLUMNS = {
            { "uuid_", Types.VARCHAR },
            { "id_", Types.BIGINT },
            { "name", Types.VARCHAR },
            { "picId", Types.BIGINT }
        };
    public static final String TABLE_SQL_CREATE = "create table vp_ViewPoint (uuid_ VARCHAR(75) null,id_ LONG not null primary key,name VARCHAR(75) null,picId LONG)";
    public static final String TABLE_SQL_DROP = "drop table vp_ViewPoint";
    public static final String ORDER_BY_JPQL = " ORDER BY viewPoint.id ASC";
    public static final String ORDER_BY_SQL = " ORDER BY vp_ViewPoint.id_ ASC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.com.hlxl.viewpoint.model.ViewPoint"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.com.hlxl.viewpoint.model.ViewPoint"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.com.hlxl.viewpoint.model.ViewPoint"),
            true);
    public static long NAME_COLUMN_BITMASK = 1L;
    public static long UUID_COLUMN_BITMASK = 2L;
    public static long ID_COLUMN_BITMASK = 4L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.com.hlxl.viewpoint.model.ViewPoint"));
    private static ClassLoader _classLoader = ViewPoint.class.getClassLoader();
    private static Class<?>[] _escapedModelInterfaces = new Class[] {
            ViewPoint.class
        };
    private String _uuid;
    private String _originalUuid;
    private long _id;
    private String _name;
    private String _originalName;
    private long _picId;
    private long _columnBitmask;
    private ViewPoint _escapedModel;

    public ViewPointModelImpl() {
    }

    @Override
    public long getPrimaryKey() {
        return _id;
    }

    @Override
    public void setPrimaryKey(long primaryKey) {
        setId(primaryKey);
    }

    @Override
    public Serializable getPrimaryKeyObj() {
        return _id;
    }

    @Override
    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    @Override
    public Class<?> getModelClass() {
        return ViewPoint.class;
    }

    @Override
    public String getModelClassName() {
        return ViewPoint.class.getName();
    }

    @Override
    public Map<String, Object> getModelAttributes() {
        Map<String, Object> attributes = new HashMap<String, Object>();

        attributes.put("uuid", getUuid());
        attributes.put("id", getId());
        attributes.put("name", getName());
        attributes.put("picId", getPicId());

        return attributes;
    }

    @Override
    public void setModelAttributes(Map<String, Object> attributes) {
        String uuid = (String) attributes.get("uuid");

        if (uuid != null) {
            setUuid(uuid);
        }

        Long id = (Long) attributes.get("id");

        if (id != null) {
            setId(id);
        }

        String name = (String) attributes.get("name");

        if (name != null) {
            setName(name);
        }

        Long picId = (Long) attributes.get("picId");

        if (picId != null) {
            setPicId(picId);
        }
    }

    @Override
    public String getUuid() {
        if (_uuid == null) {
            return StringPool.BLANK;
        } else {
            return _uuid;
        }
    }

    @Override
    public void setUuid(String uuid) {
        if (_originalUuid == null) {
            _originalUuid = _uuid;
        }

        _uuid = uuid;
    }

    public String getOriginalUuid() {
        return GetterUtil.getString(_originalUuid);
    }

    @Override
    public long getId() {
        return _id;
    }

    @Override
    public void setId(long id) {
        _columnBitmask = -1L;

        _id = id;
    }

    @Override
    public String getName() {
        if (_name == null) {
            return StringPool.BLANK;
        } else {
            return _name;
        }
    }

    @Override
    public void setName(String name) {
        _columnBitmask |= NAME_COLUMN_BITMASK;

        if (_originalName == null) {
            _originalName = _name;
        }

        _name = name;
    }

    public String getOriginalName() {
        return GetterUtil.getString(_originalName);
    }

    @Override
    public long getPicId() {
        return _picId;
    }

    @Override
    public void setPicId(long picId) {
        _picId = picId;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
            ViewPoint.class.getName(), getPrimaryKey());
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        ExpandoBridge expandoBridge = getExpandoBridge();

        expandoBridge.setAttributes(serviceContext);
    }

    @Override
    public ViewPoint toEscapedModel() {
        if (_escapedModel == null) {
            _escapedModel = (ViewPoint) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
        }

        return _escapedModel;
    }

    @Override
    public Object clone() {
        ViewPointImpl viewPointImpl = new ViewPointImpl();

        viewPointImpl.setUuid(getUuid());
        viewPointImpl.setId(getId());
        viewPointImpl.setName(getName());
        viewPointImpl.setPicId(getPicId());

        viewPointImpl.resetOriginalValues();

        return viewPointImpl;
    }

    @Override
    public int compareTo(ViewPoint viewPoint) {
        int value = 0;

        if (getId() < viewPoint.getId()) {
            value = -1;
        } else if (getId() > viewPoint.getId()) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }

        if (!(obj instanceof ViewPoint)) {
            return false;
        }

        ViewPoint viewPoint = (ViewPoint) obj;

        long primaryKey = viewPoint.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        ViewPointModelImpl viewPointModelImpl = this;

        viewPointModelImpl._originalUuid = viewPointModelImpl._uuid;

        viewPointModelImpl._originalName = viewPointModelImpl._name;

        viewPointModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<ViewPoint> toCacheModel() {
        ViewPointCacheModel viewPointCacheModel = new ViewPointCacheModel();

        viewPointCacheModel.uuid = getUuid();

        String uuid = viewPointCacheModel.uuid;

        if ((uuid != null) && (uuid.length() == 0)) {
            viewPointCacheModel.uuid = null;
        }

        viewPointCacheModel.id = getId();

        viewPointCacheModel.name = getName();

        String name = viewPointCacheModel.name;

        if ((name != null) && (name.length() == 0)) {
            viewPointCacheModel.name = null;
        }

        viewPointCacheModel.picId = getPicId();

        return viewPointCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(9);

        sb.append("{uuid=");
        sb.append(getUuid());
        sb.append(", id=");
        sb.append(getId());
        sb.append(", name=");
        sb.append(getName());
        sb.append(", picId=");
        sb.append(getPicId());
        sb.append("}");

        return sb.toString();
    }

    @Override
    public String toXmlString() {
        StringBundler sb = new StringBundler(16);

        sb.append("<model><model-name>");
        sb.append("com.hlxl.viewpoint.model.ViewPoint");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>uuid</column-name><column-value><![CDATA[");
        sb.append(getUuid());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>id</column-name><column-value><![CDATA[");
        sb.append(getId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>name</column-name><column-value><![CDATA[");
        sb.append(getName());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>picId</column-name><column-value><![CDATA[");
        sb.append(getPicId());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
